package com.example.viewpagertest;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ColorFragment extends Fragment {
	
	private String mColorRes = "北京" ;
	
	public ColorFragment() { 
		this("北京");
	}
	
	public ColorFragment(String colorRes) {
		mColorRes = colorRes;
//		setRetainInstance(true);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getString("mColorRes");
		
		// construct the RelativeLayout
		LinearLayout v = new LinearLayout(getActivity());
//		TextView text = (TextView)v.findViewById(R.id.text);
//		text.setText(mColorRes);		
		return v;
	}
	
	@Override
	public void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		outState.putString("mColorRes", mColorRes);
	}
	
}
